<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>props的基础使用</title>
</head>
<body>
  <div id="test"></div>
  <div id="test2"></div>
  <div id="test3"></div>

  <!-- 引入库：先引入核心库，再引入操作DOM的扩展库 -->
  <script type="text/javascript" src="../js/react.development.js"></script>
  <script type="text/javascript" src="../js/react-dom.development.js"></script>
  <!-- 将jsx转为js -->
  <script type="text/javascript" src="../js/babel.min.js"></script>
  <script type="text/babel">    //必须写babel，因为默认js

    class Person extends React.Component{
      render(){
        // console.log(this)
        const {name,age,sex} = this.props
        return (
          <ul>
            <li>姓名：{name}</li>
            <li>年龄：{age+1}</li>
            <li>性别：{sex}</li>
          </ul>
        )
      }
    }

    //少量数据，提示只有js才会有Number，jsx需要用{}包裹才是Number类型
    ReactDOM.render(<Person name='zhang' age={19} sex='男'/>, document.getElementById('test'))

    //大数据
    const p = {name:'li',age:23,sex:'女'}
    ReactDOM.render(<Person name={p.name} age={p.age} sex={p.sex}/>, document.getElementById('test2'))

    //大数据语法糖，批量处理，前提数据传输的key命名和类中一样
    ReactDOM.render(<Person {...p}/>, document.getElementById('test3'))

  </script>
</body>
</html>